var app = getApp();
Page({

  data: {
    content:''
  },

  onLoad: function (options) {
  
  },

  onContent:function(e){
    var content = e.detail.value;
    this.setData({
      content:content
    })
  },

  onName: function (e) {
    var name = e.detail.value;
    this.setData({
      name: name
    })
  },

  onTel: function (e) {
    var tel = e.detail.value;
    this.setData({
      tel: tel
    })
  },

  onSubmit:function(e){
    wx.showLoading({
      title: '提交中..',
    })
    var that = this;
    var content = that.data.content;
    var name = that.data.name;
    var tel = that.data.tel;
    var openId = app.globalData.openId;

    if (content == ''){
      wx.hideLoading();
      wx.showToast({
        title: '请填写反馈内容',
      })
    }else{
      wx.request({
        url: app.globalData.url+ 'addFeedBack?openId=' + openId 
        +'&content=' + content 
        + '&telephone=' + tel
        + '&name=' + name,
        success: function (res) {
          if (res.data == 'ajaxSuccess') {
            wx.hideLoading();
            wx.showToast({
              title: '提交成功',
            })
            setTimeout(function(){
              wx.switchTab({
                url: '/pages/mine/mine',
              })
            },1000)
            
          }
        }
      })
    }
  }
})